/**
 * ======================================================
 * arsstats.h
 * 
 * Primary plugin class
 * ======================================================
 *
 * The MIT License
 * 
 * Copyright (c) 2008 Matthew Maravillas
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * Version: $Id$
 */

#ifndef _INCLUDE_ARSSTATS_ARSSTATS_H_
#define _INCLUDE_ARSSTATS_ARSSTATS_H_

#include <ISmmPlugin.h>
#include <igameevents.h>
#include <iplayerinfo.h>
#include <iserverentity.h>
#include "events.h"
#include "stats.h"

#if defined WIN32 && !defined snprintf
#define snprintf _snprintf
#endif

class ArsStatsPlugin : public ISmmPlugin
{
public:
    ArsStatsPlugin() { mStats = NULL; };
    ~ArsStatsPlugin() 
    { 
        if (mStats != NULL) 
        {
            delete mStats; 
            mStats = NULL;
        }
    };

	bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late);
	bool Unload(char *error, size_t maxlen);
	bool Pause(char *error, size_t maxlen);
	bool Unpause(char *error, size_t maxlen);
	void AllPluginsLoaded();

    void ClientPutInServer(edict_t *edict, char const *name);
    void ClientDisconnect(edict_t *edict);
    bool LevelInit(const char *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background);
    void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax);

public:
	const char *GetAuthor()
	{
		return "kwatz";
	}
	const char *GetName()
	{
		return "ArsStats";
	}
	const char *GetDescription()
	{
		return "Generates additional logging messages to TF2 servers.";
	}
	const char *GetURL()
	{
		return "http://www.arsclan.net/";
	}
	const char *GetLicense()
	{
		return "MIT License";
	}
	const char *GetVersion()
	{
		return "1.0.0";
	}
	const char *GetDate()
	{
		return __DATE__;
	}
	const char *GetLogTag()
	{
		return "ARS";
	}

private:
	IServerGameDLL          *mServer;
	IVEngineServer          *mEngine;
	IGameEventManager2      *mGameEvents;
	IServerPluginHelpers    *mHelpers;
	ICvar                   *mCvar;
	IServerGameClients      *mGameClients;
	IPlayerInfoManager      *mPlayerInfoManager;

	IGameEventListener2     *mPlayerDisconnectListener;
	IGameEventListener2     *mPlayerDeathListener;
	IGameEventListener2     *mPlayerChangeClassListener;
	IGameEventListener2     *mPlayerHurtListener;
	//IGameEventListener2     *mPlayerCalledForMedicListener;
	//IGameEventListener2     *mPlayerHealedMedicCallListener;
	//IGameEventListener2     *mPlayerExtinguishedListener;
	IGameEventListener2     *mPlayerInvlunedListener;

    Stats                   *mStats;
};

extern ArsStatsPlugin gArsStatsPlugin;

PLUGIN_GLOBALVARS();

#endif //_INCLUDE_ARSSTATS_ARSSTATS_H_
